package com.ruoyi.system.service.news.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.ruoyi.system.domain.news.NewsPolicyLaw;
import com.ruoyi.system.domain.news.query.NewsPolicyLawQuery;
import com.ruoyi.system.domain.news.vo.NewsPolicyLawVo;
import com.ruoyi.system.domain.news.vo.NewsPolicyLawVo;
import com.ruoyi.system.mapper.news.NewsPolicyLawMapper;
import com.ruoyi.system.service.news.NewsPolicyLawService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class NewsPolicyLawServiceImpl extends ServiceImpl<NewsPolicyLawMapper, NewsPolicyLaw>
        implements NewsPolicyLawService {

    @Override
//    @DataScope(deptAlias = "t",userAlias = "t")
    public List<NewsPolicyLawVo> getNewsPolicyLawList(NewsPolicyLawQuery newsPolicyLawQuery) {
        if (newsPolicyLawQuery.getIfPage()) {
            PageHelper.startPage(newsPolicyLawQuery.getPageNum(), newsPolicyLawQuery.getPageSize());
        }
        List<NewsPolicyLawVo> newsPolicyLawVoList = baseMapper.getNewsPolicyLawList(newsPolicyLawQuery);
        if (!newsPolicyLawVoList.isEmpty() && newsPolicyLawQuery.getId() == null) {
            for (NewsPolicyLawVo newsPolicyLawVo:newsPolicyLawVoList) {
                newsPolicyLawVo.setContent(null);
            }
        }
        return newsPolicyLawVoList;
    }
}
